package com.excel.controller;

import com.excel.entity.EvaluateObjAddReq;
import com.excel.entity.ImportInfoVO;
import com.excel.enums.LanguageTypeEnum;
import com.excel.service.CommonExcelService;
import com.excel.util.NeptuneUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author User
 */
@RestController
@RequestMapping("/common")
public class CommonExcelController {

    @Resource
    private CommonExcelService commonExcelService;


    @PostMapping(value = "/import")
    public ImportInfoVO importEvaluateObj(@RequestParam("file") MultipartFile file,
                                                    EvaluateObjAddReq addReq,
                                                    HttpServletRequest request) {
        LanguageTypeEnum typeEnum = NeptuneUtil.getLanguageTypeByCookie(request);
        addReq.setLanguageType(typeEnum.name());
        addReq.setTypeEnum(typeEnum);
        return commonExcelService.importObj(file, addReq);
    }

}
